package com.fujifilm.project.plan.vo.request;

import java.util.List;

import org.springframework.util.StringUtils;

import com.fujifilm.project.plan.error.BusinessException;

public class RequestRecords {
    private RequestRecords() {
    }

    public record UserLoginRequest(String username, String password) {
        public UserLoginRequest {
            if (!StringUtils.hasText(username))
                throw BusinessException.of("Username cannot be null or blank");
            if (!StringUtils.hasText(password))
                throw BusinessException.of("Password cannot be null or blank");
        }
    }

    public record ProjectGroupPageListRequest(int page, int size, String filter) {
        public ProjectGroupPageListRequest {
            if (page < 0)
                throw BusinessException.of("Page number cannot be negative");
            if (size <= 0)
                throw BusinessException.of("Size must be greater than zero");
        }
    }

    public record ProjectGroupSaveRequest(long id,
            String groupName,
            String groupCode,
            String belongToGroup,
            String belongToCustomer,
            String generalDepartment,
            String department,
            int status) {
        public ProjectGroupSaveRequest {
            if (!StringUtils.hasText(groupName))
                throw BusinessException.of("Name cannot be null or blank");
            if (!StringUtils.hasText(groupCode))
                throw BusinessException.of("Code cannot be null or blank");
        }
    }

    public record ProjectGroupDeleteRequest(long id) {
        public ProjectGroupDeleteRequest {
            if (id <= 0)
                throw BusinessException.of("ID must be greater than zero");
        }
    }

    public record ProjectGroupBatchDeleteRequest(List<Long> ids) {
        public ProjectGroupBatchDeleteRequest {
            if (ids == null || ids.isEmpty())
                throw BusinessException.of("IDs must be greater than zero");
        }
    }

    public record ProjectGroupInfoRequest(long id) {
        public ProjectGroupInfoRequest {
            if (id <= 0)
                throw BusinessException.of("ID must be greater than zero");
        }
    }
}
